package Annotation;

import org.junit.Test;

import java.lang.reflect.AnnotatedType;
import java.lang.reflect.Method;

public class TestAnnotation {
    @Test
    public void test1() {
        Class<TestAnnotation> clazz = TestAnnotation.class;
        try {
            Method m1 = clazz.getMethod("show");
            MyAnnotation[] annotationsByType = m1.getAnnotationsByType(MyAnnotation.class);
            System.out.println(annotationsByType);
            for (MyAnnotation mya : annotationsByType) {
                System.out.println(mya.value());
            }
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }

    }

    @MyAnnotation("hello")
    @MyAnnotation("world")
    public void show() {

    }
}
